feat(otel): add Workflow span to InvocationOtelPlugin - #593
Conversation
caacb55 to
3a9ba39
Compare
InvocationOtelPlugin now emits a deterministic, execution-scoped Workflow root span (span ID derived from the execution ARN, INTERNAL, started at execution_start_time), exported once on a terminal invocation (SUCCEEDED->OK, FAILED->ERROR; non-terminal dropped unexported). Created unconditionally since this plugin has no default/owned tracer-provider distinction. Operation and attempt spans link to the Workflow span while remaining parented to the Invocation span. The workflow span name is configurable via a new workflow_span_name constructor kwarg. Span display names are capitalized in both plugins: "Workflow" (default) and "Invocation".
3a9ba39 to
5c3adc9
Compare
Codex AI review
Reviewed commit |
Claude AI reviewSummaryThis PR adds an execution-scoped Workflow root span to Findings
Residual test risk
Reviewed commit |
|
I think we will be covering the Residual test risk in our conformance testing. |
…rkflow Per the Java (aws/aws-durable-execution-sdk-java#572) and Python (aws/aws-durable-execution-sdk-python#593) reference plugins, the invocation-rooted plugin must NOT parent the Invocation span to the Workflow span. Under ADOT/X-Ray the Invocation span should remain a child of the active Lambda execution-environment span. - Parent the Invocation span to context.active() (the Lambda env span under ADOT), not the Workflow span. - Add a link to the Workflow span on every operation, continuation, and attempt span (the Invocation span carries no such link), so spans correlate to the one execution-scoped Workflow span while staying invocation-rooted. Resumed/replayed ops keep their deterministic self-link first, then the Workflow link (order-significant). Tests updated accordingly; 180/180 pass, tsc clean.
…d with Workflow links (#773) > **Stacked PR (gh-stack style).** Review/merge bottom-up. This stack fixes the JS OTel invocation-view parity gaps surfaced by aws/aws-durable-execution-conformance-tests#40. > > 1. #773 — Workflow root span in all provider modes; invocation-rooted + Workflow links _(base: `main`)_ > 2. #774 — `durable.operation.status` state machine _(base: #773)_ > 3. #775 — wall-clock timing so op/attempt spans nest in Invocation span _(base: #774)_ --- ## Summary Aligns `InvocationOtelPlugin` with the newer invocation-view OTel contract (asserted by aws/aws-durable-execution-conformance-tests#40) and with the Java (aws/aws-durable-execution-sdk-java#572) and Python (aws/aws-durable-execution-sdk-python#593) reference plugins. Previously the root `Workflow` span was created only in community-collector mode (`!useDefaultTracerProvider`), so ADOT/X-Ray invocation-view traces had no `Workflow` root and every `otel-invocation` conformance case failed with `span_assertions[0] (Workflow) matched no spans`. ## Changes 1. **Emit the `Workflow` root span unconditionally** (both provider modes), matching `ExecutionOtelPlugin` and the reference plugins. It keeps its deterministic execution-ARN span id (one root per execution), is finalized with `durable.execution.status` + span status `OK`/`ERROR` only on a **terminal** invocation, and is dropped un-exported while non-terminal (preserves the interrupted-timeout case). 2. **Keep the plugin invocation-rooted.** The `Invocation` span is parented to the **active context** (the Lambda execution-environment span under ADOT/X-Ray), **not** the `Workflow` span. 3. **Link operations & attempts to the `Workflow` span.** Every operation, continuation, and attempt span carries a link to the `Workflow` span for execution-scoped correlation; the `Invocation` span does not. Resumed/replayed ops keep their deterministic self-link first, then the `Workflow` link (order-significant per the contract). ## Conformance impact - Resolves `span_assertions[0] (Workflow) matched no spans` across otel-invocation cases 1-9, 11, 16, 18, 19. - Restores the required `Workflow` link on operation/attempt spans (enforced by the community/collector backend; relaxed under X-Ray via the `SPAN_LINKS` disparity flag). Remaining invocation-view parity gaps are tracked as follow-up PRs: `durable.operation.status`/`STARTED` semantics, the op-span timing envelope, and the callback-handler naming (conformance repo). ## Testing - `npm test` (otel package) — 180/180 pass - `tsc --noEmit` — clean --------- Co-authored-by: silanhe <hsilan@amazon.com>
Issue #, if available: aws/aws-durable-execution-conformance-tests#23 (comment)
Description of changes: InvocationOtelPlugin now emits a deterministic, execution-scoped Workflow root span (span ID derived from the execution ARN, INTERNAL, started at execution_start_time), exported once on a terminal invocation (SUCCEEDED->OK, FAILED->ERROR; non-terminal dropped unexported). Created unconditionally since this plugin has no default/owned tracer-provider distinction. Operation and attempt spans link to the Workflow span while remaining parented to the invocation span. The span name is configurable via a new workflow_span_name constructor kwarg (default "Workflow").
The "invocation" span is renamed to "Invocation" to match the capitalization for the "Workflow" and the configuration in other language's Otel plugins.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.